package com.ydc.ln.tutorial.algorithm.book.itjp;

// 字符串排列，打印一个客串的所有排列
public class Ex19_21 {
    public static void main(String[] args) {
        Ex19_21 ex = new Ex19_21();
        ex.displayPermutation("abc");
    }

    public void displayPermutation(String str) {
        displayPermutation("", str);
    }

    public void displayPermutation(String str1, String str2) {
        int size = str2.length();
        if (size == 0) {
            System.out.println(str1);
        } else {
            for (int i = 0; i < size; i++) {
                displayPermutation(str1 + str2.charAt(i), str2.substring(0, i)
                        + str2.substring(i + 1, size));
            }
        }
    }
}
